package com.cpecc.dao.wuzi;

import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.cpecc.model.wuzi.WuZi;
import com.cpecc.model.wuzi.XiuGaiJL;

@Repository
public class XiuGaiJLDao {

	@Resource
	private SessionFactory sessionFactory;
	
	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}
	
	public void save(XiuGaiJL xiuGaiJL){
		Session session=sessionFactory.getCurrentSession();
		session.save(xiuGaiJL);
		session.flush();
	}
	
	@SuppressWarnings("unchecked")
	public List<XiuGaiJL> getAllByWuZi(WuZi wuZi){
		String hql="from XiuGaiJL t where t.wuZi=? order by t.xiuGaiRQ desc";
		Query query=sessionFactory.getCurrentSession().createQuery(hql);
		query.setParameter(0, wuZi);
		return query.list();
	}
}
